<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>proxy-监听函数对象的操作</title>
</head>
<body>
  
  <script>

    function foo(num1, num2) {
      console.log(this, num1, num2)
    }

    const fooProxy = new Proxy(foo, {
      apply: function(target, thisArg, otherArgs) {
        console.log("监听了apply操作")
        target.apply(thisArg, otherArgs)
      },
      construct: function(target, argArray) {
        console.log("监听来了new操作")
        return new target(...argArray)
      }
    })
  
    new fooProxy("aa", "bbb")

  </script>
</body>
</html>